//
//  ProfileTableViewController.m
//  HYApp
//
//  Created by Jianbo Cai on 2020/8/21.
//  Copyright © 2020 Unidax. All rights reserved.
//

#import "ProfileTableViewController.h"
#import "PersonalProfileTableViewController.h"
#import "SecurityTableViewController.h"
#import "BankListTableViewController.h"
#import <JFBase/JFBase.h>
#import <Masonry.h>

@interface ProfileTableViewController ()

@end

@implementation ProfileTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tableView.tableFooterView = [[UIView alloc]init];
    self.tableView.separatorInset = UIEdgeInsetsZero;
    
    self.navigationItem.title = JFMainLocalizedString(@"onboarding.personal");
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self initLanguage];
}
#pragma mark - Table view data source

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(nonnull NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            PersonalProfileTableViewController *vc = [[UIStoryboard storyboardWithName:@"User" bundle:nil]instantiateViewControllerWithIdentifier:@"PersonalProfileTableViewController"];;
            [self.navigationController pushViewController:vc animated:YES];
        }else if (indexPath.row == 1) {
            SecurityTableViewController *vc = [[UIStoryboard storyboardWithName:@"User" bundle:nil]instantiateViewControllerWithIdentifier:@"SecurityTableViewController"];;
            [self.navigationController pushViewController:vc animated:YES];
        }
    }else if (indexPath.section == 1) {
        BankListTableViewController *vc = [[UIStoryboard storyboardWithName:@"User" bundle:nil]instantiateViewControllerWithIdentifier:@"BankListTableViewController"];
        vc.type = indexPath.row;
        [self.navigationController pushViewController:vc animated:YES];
    }
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 1) {
        return 20;
    }else{
        return 0;
    }
}
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    if(section == 1){
        UILabel * lab = [[UILabel alloc] init];
        lab.text = JFMainLocalizedString(@"myProfile.Account");
        UIView * tempView  = [[UIView alloc] init];
        [tempView addSubview:lab];
        AWMasFast(lab, {
            AWMasTop(tempView, 0)
            AWMasBottom(tempView, 0)
            AWMasLeft(tempView, 15)
            AWMasRight(tempView, 0)
        })
        return tempView;
    }
   return [[UIView alloc] init];
}

/*
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath];
    
    // Configure the cell...
    
    return cell;
}
*/

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

-(void)initLanguage{
    self.profileTitleLab.text  = JFMainLocalizedString(@"profile.title");
    self.securityTitleLab.text  = JFMainLocalizedString(@"myProfile.Safety");
    self.diditalTitleLab.text  = JFMainLocalizedString(@"profile.digital-assets-address");
    self.banktitleLab.text  = JFMainLocalizedString(@"profile.bank-accounts");
}

@end
